package com.qf.feigndemo.controller;

import com.qf.common.entity.User;
import com.qf.common.vo.R;
import com.qf.feigndemo.feign.ProviderClient;
import com.qf.feigndemo.feign.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FeignController {

    @Autowired
    ProviderClient providerClient;

    @Autowired
    UserClient userClient;

    @GetMapping("/test2")
    public R test2(){
        return userClient.getUserById(1);
    }

    @GetMapping("/test3")
    public R test3(){
        User user = new User();
        user.setName("zoro");
        user.setAge(28);
        user.setEmail("zoro@163.com");
        return userClient.addUser(user);
    }

    @GetMapping("/test4")
    public R test4(){
        return userClient.updateUser(1l,"zoro",29);
    }

    @GetMapping("/test5")
    public R test5(){
        return userClient.deleteUser(2);
    }

    @GetMapping("/test1")
    public String test1(){
        String echo = providerClient.echo("luffy");
        return echo;
    }



}
